FROM golang:alpine as builder

WORKDIR /build

ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn/,direct

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
    && apk update --no-cache \
    && apk upgrade \
    && apk add --no-cache bash \
            bash-doc \
            bash-completion \
    && apk add --no-cache tzdata \
    && rm -rf /var/cache/apk/*

COPY . .

RUN go mod download
RUN bash scripts/build.sh

FROM alpine as prod

ENV TZ Asia/Shanghai
ENV GIN_MODE release

WORKDIR /data/apps/mootok-web/


RUN apk update --no-cache \
    && apk upgrade

COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY --from=builder /build/build .